<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>Markdown</title>
    <script src="https://unpkg.com/vue"></script>
    <link rel="stylesheet" href="./index.css">
  </head>
  <body>
    <div id="editor">
        <textarea :value="input" @input="update"></textarea>
        <div v-html="compiledMarkdown"></div>
    </div>

    <script>
        new Vue({
            el: '#editor',
            data: {
                input: '# hello'
            },
            computed: {
                compiledMarkdown: function () {
                    return marked(this.input, { sanitize: true })
                }
            },
            methods: {
                update: _.debounce(function (e) {
                    this.input = e.target.value
                }, 300)
            }
        })
    </script>
  </body>
</html>